package com.mashibing.juc.c_025;

import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TransferQueue;

public class T09_TransferQueue {

	public static void main(String[] args) throws InterruptedException {

		TransferQueue<String> transferQueue = new LinkedTransferQueue<>();
		
		new Thread(() -> {
			try {
				System.out.println(transferQueue.take());
				System.out.println(transferQueue.take());
				System.out.println(transferQueue.take());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}).start();
		
		transferQueue.transfer("123");
		transferQueue.transfer("234");

		transferQueue.put("345");
		System.out.println(1);
		transferQueue.put("456");
		System.out.println(2);
		transferQueue.transfer("567");
		System.out.println(3);


		/*new Thread(() -> {
			try {
				System.out.println(strs.take());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}).start();*/

	}

}
